﻿using Newtonsoft.Json;
using System.Net.Mime;
using System.Text;

namespace web
{
    static class ResultsExtensions
    {
        public static IResult Html(this IResultExtensions resultExtensions, string html)
        {
            ArgumentNullException.ThrowIfNull(resultExtensions);

            return Results.Content(html, MediaTypeNames.Text.Html, Encoding.UTF8);
        }

        public static IResult NewtonJson(this IResultExtensions resultExtensions, object obj)
        {
            ArgumentNullException.ThrowIfNull(resultExtensions);

            return Results.Content(JsonConvert.SerializeObject(obj), MediaTypeNames.Application.Json, Encoding.UTF8);
        }
    }
}
